package com.aliware.tianchi.test.random;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @author lorne
 * @date 2019/6/30
 * @description
 */
class PointVal {

    private double point;
    private double maxSize;

    private double minVal;
    private double maxVal;
    private AtomicLong count;


    PointVal(double point,double chance,double maxSize) {
        this.point = point;
        this.maxSize = maxSize;
        this.minVal = (chance-point)*maxSize;
        this.maxVal = maxSize*chance;
        this.count = new AtomicLong(0);
    }


    double getPoint() {
        return point;
    }


    AtomicLong getCount() {
        return count;
    }

    double getMaxVal() {
        return maxVal;
    }

    double getMinVal() {
        return minVal;
    }

    boolean canGet(){
       double currentPoint =  count.get()/maxSize;
       return currentPoint>point;
    }


    @Override
    public String toString() {
        return String.format("point:%s,maxSize:%s,count:%s",point,maxSize,count.get());
    }
}
